//
//  NewsTableViewCell.m
//  HelpThePoor
//
//  Created by van7ish on 2016/12/1.
//  Copyright © 2016年 van7ish. All rights reserved.
//

#import "NewsTableViewCell.h"

#define cellHeight HeightScale(104)

#define coverImageViewH (cellHeight - HeightScale(15) * 2)

@implementation NewsTableViewCell

- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(WidthScale(15), 0, SCREEN_W - WidthScale(15) - self.coverImageView.frame.size.width - WidthScale(20), cellHeight - HeightScale(35))];
        _titleLabel.numberOfLines = 0;
        _titleLabel.font = FONTSIZE(17);
        _titleLabel.textColor = COLOR_FONTBLACK;
    }
    return _titleLabel;
}

- (UIImageView *)timeImageView{
    if (!_timeImageView) {
        _timeImageView = [[UIImageView alloc] initWithFrame:CGRectMake(WidthScale(15), cellHeight - HeightScale(35) + HeightScale(11.75), WidthScale(12.5), WidthScale(12.5))];
        _timeImageView.image = ImageNamed(@"time");
    }
    return _timeImageView;
}

- (UILabel *)timeLabel{
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.timeImageView.frame) + WidthScale(5), cellHeight - HeightScale(35), SCREEN_W / 3, HeightScale(35))];
        _timeLabel.font = FONTSIZE(15);
        _timeLabel.textColor = COLOR_FONTLIGHTGRAY;
    }
    return _timeLabel;
}

- (UIImageView *)coverImageView{
    if (!_coverImageView) {
        _coverImageView = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_W - coverImageViewH * 1.5 - WidthScale(20), HeightScale(15), coverImageViewH * 1.5, coverImageViewH)];
        
    }
    return _coverImageView;
}

- (UIView *)underLine{
    if (!_underLine) {
        _underLine = [[UIView alloc] initWithFrame:CGRectMake(WidthScale(10), cellHeight - 0.5, SCREEN_W - WidthScale(10) * 2, 0.5)];
        _underLine.backgroundColor = COLOR_GRAYLINE;
    }
    return _underLine;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.contentView.backgroundColor = COLOR_LIGHTBGCOLOR;
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.timeImageView];
    [self.contentView addSubview:self.timeLabel];
    [self.contentView addSubview:self.coverImageView];
    [self.contentView addSubview:self.underLine];
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
